package com.example.controller.shopping;


import cn.hutool.core.lang.Dict;
import com.example.common.Result;
import com.example.model.entity.shopping.Business;
import com.example.model.vo.MedicinesVO;
import com.example.model.vo.UserCommentVO;
import com.example.service.other.BusinessService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 商家信息表前端操作接口
 **/
@RestController
@RequestMapping("/business")
@Api(tags = "商家接口")
public class BusinessController {

    @Resource
    private BusinessService businessService;

    /**
     * 根据商家ID查询药物详细信息
     */
    //TODO
    @ApiOperation(value = "根据药物ID查询")
    @GetMapping("/selectByMedicinesId")
    public Result selectByMedicinesId(@RequestParam Long MedicinesId) {
        List<MedicinesVO> list=new ArrayList<>();
        return Result.success(list);
    }
    /**
     * 新增
     */
    @ApiOperation(value = "新增商家")
    @PostMapping("/add")
    public Result add(@RequestBody Business business) {
        businessService.add(business);
        return Result.success();
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除商家")
    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Integer id) {
        businessService.deleteById(id);
        return Result.success();
    }

    /**
     * 批量删除
     */
    @ApiOperation(value = "批量删除商家")
    @DeleteMapping("/delete/batch")
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        businessService.deleteBatch(ids);
        return Result.success();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改商家")
    @PutMapping("/update")
    public Result updateById(@RequestBody Business business) {
        businessService.updateById(business);
        return Result.success();
    }

    /**
     * 根据ID查询
     */
    @ApiOperation(value = "根据ID查询商家")
    @GetMapping("/selectById/{id}")
    public Result selectById(@PathVariable Integer id) {
        Business business = businessService.selectById(id);
        return Result.success(business);
    }

    /**
     * 查询所有
     */
    @ApiOperation(value = "查询所有商家")
    @GetMapping("/selectAll")
    public Result selectAll(Business business) {
        List<Business> list = businessService.selectAll(business);
        return Result.success(list);
    }

    /**
     * 分页查询
     */
    @ApiOperation(value = "分页查询商家")
    @GetMapping("/selectPage")
    public Result selectPage(Business business,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10") Integer pageSize) {
        PageInfo<Business> page = businessService.selectPage(business, pageNum, pageSize);
        return Result.success(page);
    }
    /**
     * 医院医生预约排行统计
     */
    @GetMapping("/selectBar")
    public Result selectBar() {
        List<Dict> dictList=businessService.selectBar();
        return Result.success(dictList);
    }
}
